/**
 * 将后端返回的表单数据格式化为前端需要的格式
 * @data {array} 后端返回的数据
 */
const useConvertForm = (data) => {
  const formList = [];
  data.forEach((item) => {
    const rows = Array.from(new Set(item.items.map((el) => el.row)));
    const list = [];
    rows.forEach((row) => {
      const arr = item.items.filter((el) => el.row === row);
      list.push(arr);
    });
    formList.push({
      name: item.groupName,
      list,
    });
  });
  return formList;
};
export default useConvertForm;
